<?php
namespace app\admin\controller;

use app\admin\model\SystemManager;
use app\admin\model\SystemNode;
use think\Db;
use think\Response;

class Index extends CheckLogin
{
    public function index() {
        $this->assign('userName', session('userName'));
        return $this->fetch('/index');
    }
    public function main()
    {
        return $this->fetch(':main');
    }

    public function menu()
    {
        $systemNode = new SystemNode();
        $userId = $this->userId;
        $manager = Db::table(SystemManager::$tableName)->where('id='.$userId)->find();
        $nodeData = $systemNode->getUserNodes($manager['typeid']);
        session('menus', $nodeData['menus']);
        session('rules', $nodeData['rules']);
        return Response::create($nodeData['menus'], 'json');
    }
}
